<?php $this->load->module('mobile/index/header', $common);?>
<style type="text/css">
    .list-item .info h5{text-overflow:clip;white-space:normal;padding-top:3px;line-height: normal}
</style>
    <div class="content">
        <div class="list-search">
            <dl>
                <dd>
                    <form action="" method="post" id="searchForm">
                        <input type="search" id="search_name" autocomplete="off" placeholder="搜索攻略">
                        <a href="javascript:void(0)" class="search_btn"></a>
                    </form>
                </dd>
            </dl>
        </div>
        <div id="list">
            <?php foreach ($datalist as $v) { ?>
            <a href="<?php echo $v['link']?>">
                <div class="list-item fn-clear">
                    <div class="pic">
                        <img src="<?php echo $v['file_url'];?>" onerror="this.error=null;this.src='<?php echo URLPRE;?>static/public/images/nophoto.jpg'">
                    </div>
                    <div class="info">
                        <h5><?php echo $v['subject'];?></h5>
                        <div class="bottom">
                            <p><span class="view"><?php echo $v['view'];?></span></p>
                            <p><span><?php echo $v['author'];?></span></p>
                        </div>
                    </div>
                </div>
            </a>
            <?php }?>
        </div>
        <a href="javascript:;" class="btn-grey btn">加载更多</a>
    </div>
<?php $this->load->module('mobile/index/footer', $common);?>
<script type="text/javascript">
    $(function(){
        var slid = $("#sliderimg").slider({
            loop: true
        });
        var page = <?php echo $page+1;?>;
        var keyword = '<?php echo $keyword?>';
        var url = '<?php echo site_url('mobile/trips/index');?>';
        $('.btn-grey').click(function(){
            var $this = $(this);
            $this.text('加载中...');
            $.get(url+(url.indexOf('?')!=-1 ?'&':'/?')+'isajax=1&keyword='+keyword+'&page='+page+'&category=<?php echo $_GET[category];?>', function(data){
                if(data.length>0){
                    var html = '';
                    for(var i =0; i<data.length; i++){
                        var item = data[i];
                        html += '<a href="'+ item.link +'">' +
                        '<div class="list-item fn-clear"><div class="pic">' +
                        '<img src="'+ item.file_url +'">' +
                        '</div><div class="info">' +
                        '<h5>'+ item.subject +'</h5>' +
                        '<div class="bottom"><p><span class="view">'+ item.view +'</span></p>' +
                        '<p><span>'+ item.author +'</span></p>' +
                        '</div></div></div></a>';
                    }
                    $('#list').append(html);
                    page ++;
                }else{
                    $.dialog({
                        style:'tip',
                        width:200,
                        closeTime:1000,
                        content: '<p style="text-align: center">没有更多了</p>'
                    }).open();
                }
                $this.text('加载更多');
            },'json');
        });
        $('.search_btn').click(function () {
            keyword = $('#search_name').val();
            if(keyword.length> 0){
                keyword = encodeURIComponent(keyword);
                window.location.href = url+(url.indexOf("?") > -1 ? "&" : "?")+'keyword='+keyword;
            }
        });
    });
</script>